package com.pagonxt.hal.platform.utils;

public class LockUtils {

    private final static Object lock = new Object();

    public static void toWait(Object lock, int timeout) {
        synchronized (lock) {
            try {
                if(timeout == 0) {
                    lock.wait();
                } else {
                    lock.wait(timeout);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    public static void toWait(int timeout) {
        toWait(lock, timeout);
    }

    public static void toNotify(Object lock) {
        try {
            synchronized (lock) {
                lock.notify();
            }
        } catch (IllegalMonitorStateException e) {
            e.printStackTrace();
        }
    }
    public static void toNotify() {
        toNotify(lock);
    }


}